#define _CRT_SECURE_NO_WARNINGS 1
#include "game.h"
void menu()
{
	printf("press 1 play the game\n");
	printf("press 0 quit the game\n");
}

void game()
{
	char board[H][L] = { 0 };
	IBroad(board, H, L);
	DBoard(board, H, L);
	char ret = 0;
	while (1)
	{
		PlayAction(board, H, L);
		DBoard(board, H, L);
		ret = CheckWin(board, H, L);
		if (ret != 'C')
		{
			break;
		}
		PCAction(board,H,L);
		DBoard(board, H, L);
		ret = CheckWin(board, H, L);
		if (ret != 'C')
		{
			break;
		}
	}
	if (ret == '*')
	{
		printf("player won!\n");
	}
	else if (ret == '#')
	{
		printf("PC won!\n");
	}
	else if (ret == 'Q')
	{
		printf("tie!\n");
	}
}

int main()
{
	int input = 0;
	srand((unsigned int)time(NULL));
	do
	{
		menu();
		scanf("%d", &input);
		switch (input)
		{
		case 1:
			game();
			break;
		case 0:
			printf("leaving the game....\n");
			break;
		default:
			printf("error input for the command,please press 0 or 1\n");
		}
	} while (input);
	return 0;
}